<!DOCTYPE html>
<html>
<head>
	<title>展示</title>
</head>
<body>
	<div>倒记时	<span id="hour">时</span><span id="min">分</span><span id="sec">秒</span>	</div>
<table border="1">
	<tr>
		<th>商品名称</th>
		<th>图片</th>
		<th>数量</th>
		<th>价格</th>
		<th>操作</th>
	</tr>
	<?php  foreach($data as $key=>$v){ ?>
	<tr>
		<th><?php echo $v['name'] ?></th>
		<th><img src="img.jpg"></th>
		<th><?php echo $v['stock'] ?></th>
		<th><?php echo $v['price'] ?></th>
		<th><input type="button" id="btn" value="抢购" data_id="<?php echo $v['id'] ?>" name=""></th>
	</tr>
	<?php } ?>
</table>
</body>
</html>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
	window.setInterval(function(){
		$.getJSON('time.php',"",function(e){
			$("#hour").html(e.hour+"时");
			$("#min").html(e.min+"分");
			$("#sec").html(e.sec+"秒");
		});
	},1000);
	$("#btn").click(function(){
		var id=$(this).attr("data_id");
		$.ajax({
			url:"qiang.php",
			data:{id:id},
			dataType:"json",
			type:"post",
			success:function(res){
				alert(res.msg);
				location.reload();
			}
		});
	});
</script>
